winsafe\taskschd\com_interfaces/
iprincipal.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::macros::*;
6use crate::ole::privs::*;
7use crate::prelude::*;
8use crate::taskschd::vts::*;
9
10com_interface! { IPrincipal: "d98d51e5-c9b4-496a-a9c1-18980261cf0f";
11	/// [`IPrincipal`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nn-taskschd-iprincipal)
12	/// COM interface.
13	///
14	/// Automatically calls
15	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
16	/// when the object goes out of scope.
17	///
18	/// # Examples
19	///
20	/// ```no_run
21	/// use winsafe::{self as w, prelude::*};
22	///
23	/// let task: w::ITaskDefinition; // initialized somewhere
24	/// # let task = unsafe { w::ITaskDefinition::null() };
25	///
26	/// let principal = task
27	///     .QueryInterface::<w::IPrincipal>()?;
28	/// # w::HrResult::Ok(())
29	/// ```
30}
31
32impl oleaut_IDispatch for IPrincipal {}
33impl taskschd_IPrincipal for IPrincipal {}
34
35/// This trait is enabled with the `taskschd` feature, and provides methods for
36/// [`IPrincipal`](crate::IPrincipal).
37///
38/// Prefer importing this trait through the prelude:
39///
40/// ```no_run
41/// use winsafe::prelude::*;
42/// ```
43pub trait taskschd_IPrincipal: oleaut_IDispatch {
44	/// [`IPrincipal::get_RunLevel`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-iprincipal-get_runlevel)
45	/// method.
46	#[must_use]
47	fn get_RunLevel(&self) -> HrResult<co::TASK_RUNLEVEL> {
48		let mut rl = co::TASK_RUNLEVEL::default();
49		HrRet(unsafe { (vt::<IPrincipalVT>(self).get_RunLevel)(self.ptr(), rl.as_mut()) })
50			.to_hrresult()
51			.map(|_| rl)
52	}
53
54	/// [`IPrincipal::put_RunLevel`](https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-iprincipal-put_runlevel)
55	/// method.
56	fn put_RunLevel(&self, run_level: co::TASK_RUNLEVEL) -> HrResult<()> {
57		HrRet(unsafe { (vt::<IPrincipalVT>(self).put_RunLevel)(self.ptr(), run_level.raw()) })
58			.to_hrresult()
59	}
60}